# $Id$
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>
# Contributor: Pierre Schmitz <pierre@archlinux.de>

pkgname=kdepimlibs4
pkgver=4.14.10
_kdeappver=15.04.3
pkgrel=11
pkgdesc="KDE4 PIM Libraries"
arch=('i686' 'x86_64')
url='https://projects.kde.org/projects/kde/kdepimlibs'
license=('GPL' 'LGPL')
depends=('kdelibs' 'libakonadi-qt4' 'libical' 'qjson')
makedepends=('cmake' 'automoc4' 'boost' 'cyrus-sasl' 'akonadi-qt4')
conflicts=('kdepimlibs')
provides=('kdepimlibs')
replaces=('kdepimlibs')
source=("http://download.kde.org/Attic/applications/${_kdeappver}/src/kdepimlibs-${pkgver}.tar.xz"
   kdepimlibs4-bug338658-1.patch::"https://quickgit.kde.org/?p=kdepimlibs.git&a=commitdiff&h=4429619&o=plain"
   kdepimlibs4-bug338658-2.patch::"https://quickgit.kde.org/?p=kdepimlibs.git&a=commitdiff&h=d8b5da7&o=plain")
sha1sums=('8db2f59b8a33f4d1bbebfdff8b772d30669c9932'
          '453bc1b79453336c6a02babfc44ce8381eebc40a'
          '0df47345dd630aa2f31a62f8cf0c062df3c25c67')

prepare() {
  mkdir -p build

# Fix https://bugs.kde.org/show_bug.cgi?id=338658
  cd kdepimlibs-$pkgver
  patch -p1 -i ../kdepimlibs4-bug338658-1.patch
  patch -p1 -i ../kdepimlibs4-bug338658-2.patch

# Don't build gpgme++ 
  sed -e '/gpgme++/d' -e '/qgpgme/d' -i CMakeLists.txt
}

build() {
  cd build
  cmake ../kdepimlibs-${pkgver} \
    -DCMAKE_BUILD_TYPE=Release \
    -DKDE4_BUILD_TESTS=OFF \
    -DCMAKE_SKIP_RPATH=ON \
    -DCMAKE_INSTALL_PREFIX=/usr
  make
}

package() {
  cd build
  make DESTDIR="${pkgdir}" install

# Conflicts with KF5
  rm -r "$pkgdir"/usr/{bin,share/{akonadi,config.kcfg}}
}
